<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>04孩子节点</title>
    <script>
        window.onload = function(){
            var father = document.getElementsByTagName("ul")[0];
            alert(father.children.length);
            var cs = father.childNodes;
            for(var i=0;i<cs.length;i++){
                if(cs[i].nodeType==1){
                    //不加nodeType判断，在高版本浏览器会报错
                    cs[i].style.backgroundColor = "pink";
                }
            }
        }
    </script>
</head>
<body>
<div>
    <ul>
        <li>123</li>
        <li>123</li>
        <li>123</li>
    </ul>
</div>
</body>
</html>